package com.cn.dao.impl;

import java.sql.SQLException;
import java.util.List;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import com.cn.dao.CartDao;
import com.cn.dao.ProductDao;
import com.cn.domain.Cart;
import com.cn.domain.Product;
import com.cn.utils.DBUtils;

public class ProductDaoImpl implements ProductDao{
	
	//根据所有的热卖商品的信息显示到首页
	public List<Product> queryAllCart(int pageSize) {
		List<Product> list=null;
		try {
			list=DBUtils.getQuryRunner().query("select * from HWUA_PRODUCT  where HP_ID in(select t.HP_ID from (select HP_ID from HWUA_ORDER_DETAIL  group by HP_ID  order by count(*) desc,sum(HOD_QUANTITY) desc) t where rownum<="+pageSize+")",new BeanListHandler<Product>(Product.class));
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}
}
